library(ggplot2)
library("cowplot")
library(ggpubr)
Registered S3 method overwritten by 'data.table':
method from
print.data.table
Attaching package: ‘ggpubr’
The following object is masked from ‘package:cowplot’:
get_legend
library(phyloseq)
library (ggsci)
rr my16stheme <- theme_bw()+ theme(plot.title = element_text(family =, face = , size = (25)), panel.background = element_blank(), panel.border = element_rect(fill=NA,color = , size = 1), panel.spacing= unit(0.7,), strip.text= element_text(size=20, family =, face=), legend.title = element_text(colour = , face = ,family =,size = (20)), legend.text = element_text(face = , colour=,family = ,size = (18) ), axis.title = element_text(family = , face = , size = (20), colour = ), axis.text = element_text(family = ,face = , colour = , size = (18)))
#Data import
phy <- readRDS("breathe_sputum_phyloseq_trial_13Dec2021.RDS")
Trial <-data.frame (sample_data(phy))
#----------__Subsettting data-----------------
colnames(Trial)
[1] "templateDNA_16SqPCR_copies" "Shannon" "Simpson"
[4] "InvSimpson" "site" "studyno"
[7] "acut_exac12m" "hospitalised12m" "reason_hospi"
[10] "antibiotic12m" "any3_reasons" "any3_reasons.1"
[13] "adherence" "visit" "visit_date"
[16] "fev1z" "weight" "height"
[19] "weightcat" "f24mrcscore" "f41shuty"
[22] "FEV1_baseline" "FEVpcpred" "FVC"
[25] "FVCZ" "FVCpcpred" "FEV1FVC"
[28] "FEV1FVCZ" "cd4" "vload"
[31] "sex" "dob" "bmi"
[34] "agey" "zwauk" "zhauk"
[37] "zbmiuk" "vllog" "vlsup"
[40] "vlsup400" "vlsup40" "normalbmi"
[43] "normalwaz" "normalhaz" "durartgp"
[46] "cd4gp" "agegpsym" "abnrr"
[49] "abnsat" "abnhr" "startfollowup"
[52] "enrolmonth" "agegp" "ageyart"
[55] "duryart" "duryartgp" "attendschool"
[58] "datehiv" "artdrug1stline" "artdrug2ndline"
[61] "endfollowup" "exitreason" "dow"
[64] "dod" "lastvisit" "visittotno"
[67] "lastvisitdate" "endtreatddate" "endtreatdate"
[70] "treatstopreason" "group" "f25cough"
[73] "f11cotri" "f13drugs_3tc" "f13drugs_abc"
[76] "f13drugs_atv" "f13drugs_azt" "f13drugs_d4t"
[79] "f13drugs_ddi" "f13drugs_efv" "f13drugs_lpv"
[82] "f13drugs_nvp" "f13drugs_tnf" "f13drugs_other"
[85] "f13drugs_spec" "f14adm" "f15nadm"
[88] "f16tbtreat" "f17notbtreat" "f18breathe"
[91] "f27sputum" "sc04sccurrent" "sc05gradesc"
[94] "sc06misssc" "sc08repsc" "artreg"
[97] "sp03date" "sampling_month" "colmonthgp_mal2"
[100] "colmonthgp_mal3" "colmonthgp_zim3" "colmonthgp1"
[103] "colmonthgp2" "sp05time" "sp06spvol"
[106] "sp07indid" "sp08ind" "sp09nosamp"
[109] "sp10osat" "sp11eff_bleed" "sp11eff_vomit"
[112] "sp11eff_wheeze" "sp11eff_breath" "sp11eff_cough"
[115] "sp11eff_none" "sp12bdr" "sp13osata"
[118] "trial_arm" "sp14bcode" "sp15comm"
[121] "sp16dater" "sp17date2" "collection_date_redcap"
[124] "sp18labnopr" "comments_from_lab" "names"
[127] "all_3" "visit012" "visit1218"
[130] "visit018" "only2visits" "one_visit"
[133] "studyno_baseline" "ageyenrl_baseline" "agegpenrl_baseline"
[136] "ageyart_baseline" "duryart_baseline" "duryartgp_baseline"
[139] "weightcat_baseline" "FEV1_baseline.1" "f25cough_baseline"
[142] "f24mrcscore_baseline" "f36rr_baseline" "f37hr_baseline"
[145] "f38sat_baseline" "f11cotri_baseline" "f14adm_baseline"
[148] "f15nadm_baseline" "f16tbtreat_baseline" "f17notbtreat_baseline"
[151] "f18breathe_baseline" "f27sputum_baseline" "attendschool_baseline"
[154] "sc05gradesc_baseline" "sc06misssc_baseline" "sc08repsc_baseline"
[157] "cd4enrl_baseline" "vlenrl_baseline" "datehiv_baseline"
[160] "artdrug1stline_baseline" "artdrug2ndline_baseline" "ysincediag_baseline"
[163] "ageatdiagy_baseline" "ageatarty_baseline" "shutm_baseline"
[166] "artreg_baseline" "mrcgr1_baseline" "bmienrl_baseline"
[169] "zwaukenrl_baseline" "zhaukenrl_baseline" "zbmiukenrl_baseline"
[172] "vlenrllog_baseline" "vlenrlsup_baseline" "vlenrlsup400_baseline"
[175] "vlenrlsup40_baseline" "normalbmi_baseline" "normalwaz_baseline"
[178] "normalhaz_baseline" "durartgp_baseline" "cd4gp_baseline"
[181] "agegpsym_baseline" "abnrr_baseline" "abnsat_baseline"
[184] "abnhr_baseline"
summary(Trial$templateDNA_16SqPCR_copies)
Min. 1st Qu. Median Mean 3rd Qu. Max.
169 25952 95830 355481 346819 7786891
Trial$templateDNA_16SqPCR_copies <-log10(Trial$templateDNA_16SqPCR_copies)
summary(Trial$templateDNA_16SqPCR_copies)
Min. 1st Qu. Median Mean 3rd Qu. Max.
2.227 4.414 4.982 4.952 5.540 6.891
#------Trial arms- How many samples were collected from site-at each timepoint------------
#use trial arms data and split into timepoints to compute data collected at each for each arm
tmpt_1 <-Trial[which(Trial$visit=="Baseline"),]#331
tmpt_12<-Trial[which(Trial$visit=="Week 48"),]#304
tmpt_18<-Trial[which(Trial$visit=="Week 72"),]#240
#---Prevalence Totals in main trial data-------------
#Subsetting data into AZM and placebo
AZM<-Trial[which(Trial$trial_arm=="AZM"),]#441
Placebo<-Trial[which(Trial$trial_arm=="Placebo"),]#434
AZM1<-tmpt_1[which(tmpt_1$trial_arm=="AZM"),]#164
AZM12<-tmpt_12[which(tmpt_12$trial_arm=="AZM"),]#154
AZM18<-tmpt_18[which(tmpt_18$trial_arm=="AZM"),]#123
AZM012<-AZM[which(AZM$visit!="Week 72"),]
AZM012p<-AZM[which(AZM$visit!="Week 72" & AZM$visit012=="yes"),]
AZM1218p<-AZM[which(AZM$visit!="Baseline" & AZM$visit1218=="yes"),]
AZM018p<-AZM[which(AZM$visit!="Week 48" & AZM$visit018=="yes"),]
AZM3p<-AZM[which(AZM$all_3=="yes"),]
Plac1<-tmpt_1[which(tmpt_1$trial_arm=="Placebo"),]#167
Plac12<-tmpt_12[which(tmpt_12$trial_arm=="Placebo"),]#150
Plac18<-tmpt_18[which(tmpt_18$trial_arm=="Placebo"),]#117
Placebo012p<-Placebo[which(Placebo$visit!="Week 72" & Placebo$visit012=="yes"),]
Placebo1218p<-Placebo[which(Placebo$visit!="Baseline" & Placebo$visit1218=="yes"),]
Placebo018p<-Placebo[which(Placebo$visit!="Week 48" & Placebo$visit018=="yes"),]
Placebo3p<-Placebo[which(Placebo$all_3=="yes"),]
summary(AZM12$templateDNA_16SqPCR_copies)
Min. 1st Qu. Median Mean 3rd Qu. Max.
2.406 4.077 4.646 4.620 5.207 6.378
#AZM and Placebo at all visits
rr azmplac<-ggplot(Trial, aes(x=trial_arm, y=templateDNA_16SqPCR_copies, shape=trial_arm, fill=trial_arm)) + geom_jitter(width = 0.2)+ geom_boxplot()+ scale_fill_manual(values=c(#A087BC, #FFF468))+ facet_wrap()+coord_cartesian(ylim = c(2, 8))+ #stat_summary(fun = ,size = 0.5)+ stat_compare_means( method= .test,comparisons=list(c(, )), size=6)+ labs(x=NULL, y=\16S copies in log10)+my16stheme azmplac
#AZM at baseline and 48 weeks
rr fig1<-ggpaired(AZM012p,x=, y=_16SqPCR_copies, line.size = 0.1,line.color = #5C5B58, fill = , palette= c(#E1D0FF, #8662BD))+coord_cartesian(ylim = c(2, 8))+ stat_compare_means( paired=TRUE, method= .test,comparisons=list(c(, 48)), size=6)+ labs(x=at Baseline and 48 (n=146), y=\16S copies in log10)+my16stheme+theme(legend.position=) fig1
#AZM at 48 and 72 weeks
rr fig2<-ggpaired(AZM1218p,x=, y=_16SqPCR_copies, line.size = 0.1, line.color = #5C5B58,fill = , palette= c(#8662BD, #32224A))+coord_cartesian(ylim = c(2, 8))+ stat_compare_means( paired=TRUE, method= .test,comparisons=list(c(48, 72)), size=6)+ labs(x=at Week 48 and 72 (n=116), y=\16S copies in log10)+my16stheme+theme(legend.position=) fig2
#AZM at baseline and 72 weeks
rr fig3<-ggpaired(AZM018p,x=, y=_16SqPCR_copies, line.size = 0.1,line.color = #5C5B58, fill = ,palette= c(#E1D0FF, #32224A))+coord_cartesian(ylim = c(2, 8))+ stat_compare_means( paired=TRUE, method= .test,comparisons=list(c(, 72)), size=6)+ labs(x=at Week 48 and 72 (n=115), y=\16S copies in log10)+my16stheme+theme(legend.position=) fig3
#Obtaining legends #AZM
rr library (ggsci) fig1leg<-ggpaired(AZM3p,x=, y=_16SqPCR_copies, line.size = 0.1,line.color = , fill = , palette= c(#E1D0FF,#8662BD,#32224A))+coord_cartesian(ylim = c(2, 8))+ #stat_compare_means( paired=TRUE, method= ,comparisons=list(c(, 48, 72)), size=6)+ labs(x=at Baseline and 48 (n=146), y=\16S copies in log10)+my16stheme fig1leg
rr
leg <- get_legend(fig1leg)
legAZM<-as_ggplot(leg)
rr library(cowplot) AZM_all_visit16Scopies<-cowplot::plot_grid(fig1,fig2, fig3,legAZM, nrow = 1, ncol = 4, rel_widths = c(2,2,2, 1) , rel_heights = c(2,2,2, 1)) AZM_all_visit16Scopies
#Placebo
rr #Placebo #Baseline and Week 48 fig4<-ggpaired(Placebo012p,x=, y=_16SqPCR_copies, line.size = 0.1, line.color = #5C5B58,fill = , palette= c(#fff9ae, #dab600))+coord_cartesian(ylim = c(2, 8))+ stat_compare_means( paired=TRUE, method= .test,comparisons=list(c(, 48)), size=6)+ labs(x=at Baseline and 48 (n=143), y=\16S copies in log10)+my16stheme+theme(legend.position=)
fig4
rr fig5<-ggpaired(Placebo1218p,x=, y=_16SqPCR_copies, line.size = 0.1, line.color = #5C5B58,fill = , palette= c(#dab600, #554904))+coord_cartesian(ylim = c(2, 8))+ stat_compare_means( paired=TRUE, method= .test,comparisons=list(c(48, 72)),size=6)+ labs(x=at Week 48 and 72 (n=112), y=\16S copies in log10)+my16stheme+theme(legend.position=) fig5
rr NA NA
rr fig6<-ggpaired(Placebo018p,x=, y=_16SqPCR_copies, line.size = 0.1,line.color = #5C5B58, fill = , palette= c(#fff9ae, #554904))+coord_cartesian(ylim = c(2, 8))+ stat_compare_means( paired=TRUE, method= .test,comparisons=list(c(, 72)),size=6)+ labs(x=at Baseline and 72 (n=110), y=\16S copies in log10)+my16stheme+theme(legend.position=) fig6
#Placebo legend
rr library (ggsci) #Placebo3p not working so AZM3p used but with different colors to generate the Placebo legend fig1t<-ggpaired(AZM3p,x=, y=_16SqPCR_copies, line.size = 0.1,line.color = , fill = , palette= c(#fff9ae,#dab600, #554904))+coord_cartesian(ylim = c(2, 8))+ #stat_compare_means( paired=TRUE, method= ,comparisons=list(c(, 48, 72)), size=6)+ labs(x=at all visits, y=\16S copies in log10)+my16stheme fig1t
rr
leg <- get_legend(fig1t)
legPla<-as_ggplot(leg)
rr library(cowplot) Placebo_all_visit16Scopies<-cowplot::plot_grid(fig4,fig5,fig6,legPla, nrow = 1, ncol = 4, rel_widths = c(2,2,2, 1) , rel_heights = c(2,2,2, 1)) Placebo_all_visit16Scopies
rr tem16S<-cowplot::plot_grid(azmplac, AZM_all_visit16Scopies, Placebo_all_visit16Scopies, nrow = 3, ncol = 1, scale = .9, vjust=1.5, hjust= c(-3.5,-6.2,-5.0), labels = c(vs. Placebo at all visits, samples only at all visits, samples only at all visits), label_size = 20, label_fontfamily = , label_fontface = ) tem16S
rr
tem16Sb<-cowplot::plot_grid(azmplac, AZM_all_visit16Scopies, Placebo_all_visit16Scopies, nrow = 3, ncol = 1, scale = .85, vjust=1.5, hjust= c(-1.92,-1.82,-1.6), labels = c() AZM vs. Placebo at all visits, ) AZM samples only at all visits, ) Placebo samples only at all visits), label_size = 20, label_fontfamily = , label_fontface = , label_colour = blue) tem16Sb
ggsave(\16S_copies_final13thDec.pdf, tem16Sb, width = 55, height = 50, units = )
#ALPHA DIVERSITY
#AZM and Placebo at all visits
rr #Shannon #AZM and Placebo at three timepoint #Final azmplacA<-ggplot(Trial, aes(x=trial_arm, y=Shannon, shape=trial_arm, fill=trial_arm)) + geom_jitter(width = 0.2)+coord_cartesian(ylim = c(0, 4.5))+ geom_boxplot()+ scale_fill_manual(values=c(#A087BC, #FFF468))+ facet_wrap()+ #stat_summary(fun = , geom = ,width=0.5,size = 0.5, color = 3)+ stat_compare_means( method= .test,comparisons=list(c(, )),size=6)+ labs( x=NULL, y=index)+ my16stheme azmplacA
#AZM at baseline and 48 weeks
rr #Azithromycin #Baseline and Week 48 fig1A<-ggpaired(AZM012p,x=, y=, line.size = 0.1,line.color = #5C5B58, fill = , palette= c(#E1D0FF, #8662BD))+coord_cartesian(ylim = c(0, 4.5))+ stat_compare_means( paired=TRUE, method= .test,comparisons=list(c(, 48)),size=6)+ labs(x=\(n=146)\, y=\Shannon index\)+my16stheme+theme(legend.position=) fig1A
#AZM at 48 and 72 weeks
rr fig2A<-ggpaired(AZM1218p,x=, y=, line.size = 0.1,line.color = #5C5B58, fill = , palette= c(#8662BD, #32224A))+coord_cartesian(ylim = c(0, 4.5))+ stat_compare_means( paired=TRUE, method= .test,comparisons=list(c(48, 72)),size=6)+ labs(x=\(n=116)\, y=\Shannon index\)+my16stheme+theme(legend.position=, axis.title.y =element_blank(),axis.line = element_line(size = 0.1, colour = ) ) fig2A
#AZM at baseline and 72 weeks
rr fig3A<-ggpaired(AZM018p,x=, y=, line.size = 0.1, line.color = #5C5B58,fill = , palette= c(#E1D0FF, #32224A))+coord_cartesian(ylim = c(0, 4.5))+ stat_compare_means( paired=TRUE, method= .test,comparisons=list(c(, 72)),size=6)+ labs(x=\(n=115)\, y=\Shannon index\)+my16stheme+theme(legend.position=, axis.title.y =element_blank(), axis.line = element_line(size = 0.1, colour = )) fig3A
rr library(cowplot) AZM_all_visitShannon<-cowplot::plot_grid(fig1A,fig2A, fig3A,legAZM, nrow = 1, ncol = 4, rel_widths = c(2.3,2,2, 1) , rel_heights = c(2,2,2, 1), align = AZM_all_visitShannon
#Placebo
rr #Placebo #Baseline and Week 48
fig4A<-ggpaired(Placebo012p,x=, y=, line.size = 0.1,line.color = #5C5B58, fill = ,palette= c(#fff9ae, #dab600))+coord_cartesian(ylim = c(0, 5))+ stat_compare_means( paired=TRUE, method= .test,comparisons=list(c(,48)),size=6)+ labs(x=\(n=143)\, y=\Shannon index\)+my16stheme+theme(legend.position=) fig4A
rr fig5A<-ggpaired(Placebo1218p,x=, y=, line.size = 0.1,line.color = #5C5B58,fill = ,palette= c(#dab600, #554904))+coord_cartesian(ylim = c(0, 5))+ stat_compare_means( paired=TRUE, method= .test,comparisons=list(c(48, 72)),size=6)+ labs(x=\(n=112)\, y=\Shannon index\)+my16stheme+theme(legend.position=, axis.title.y =element_blank(), axis.line = element_line(size = 0.1, colour = )) fig5A
rr fig6A<-ggpaired(Placebo018p,x=, y=, line.size = 0.1, line.color = #5C5B58,fill = , palette= c(#fff9ae, #554904))+coord_cartesian(ylim = c(0, 5))+ stat_compare_means( paired=TRUE, method= .test,comparisons=list(c(, 72)),size=6)+ labs(x=\(n=110)\, y=\Shannon index\)+my16stheme+theme(legend.position=, axis.title.y =element_blank(), axis.line = element_line(size = 0.1, colour = )) fig6A
rr library(cowplot) Placebo_all_visitShannon<-cowplot::plot_grid(fig4A,fig5A,fig6A,legPla, nrow = 1, ncol = 4, rel_widths = c(2.3,2,2, 1) , rel_heights = c(2,2,2, 1), align = Placebo_all_visitShannon
rr temShannonA<-cowplot::plot_grid(azmplacA, AZM_all_visitShannon, Placebo_all_visitShannon, nrow = 3, ncol = 1, scale = .8, labels = c() AZM and Placebo at all visits, ) AZM arm only, ) Placebo arm only), label_size = 21, label_fontfamily = , label_fontface = , label_colour = blue,axis = align = vjust = c(2.5, 2.0,2.0), hjust = c(-1.6, -3.3, -2.7), rel_widths = c(2.5,5.5, 5.5)) temShannonA
ggsave(_final13thDec2021.pdf, temShannonA, width = 50, height = 50, units = )